package com.ruoyi.mobile.project.oms.service;

import com.github.pagehelper.PageHelper;
import com.ruoyi.db.pms.domain.PmsBrand;
import com.ruoyi.db.pms.domain.query.PmsBrandQueryVo;
import com.ruoyi.db.pms.mapper.PmsBrandMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

@Service
public class WxOmsBrandService
{
    @Autowired
    private PmsBrandMapper brandMapper;

    public List<PmsBrand> query(Integer page, Integer limit, String sort, String order)
    {
        PmsBrandQueryVo brandQueryVo = new PmsBrandQueryVo();
        brandQueryVo.setOrder(order);
        brandQueryVo.setSort(sort);

        PageHelper.startPage(page, limit);
        return brandMapper.selectPmsBrandList(brandQueryVo);
    }

    public List<PmsBrand> query(Integer page, Integer limit)
    {
        return query(page, limit, null, null);
    }

    /**
     * 根据id获取某品牌
     *
     * @author 张涛
     * @param id
     * @return
     */
    public PmsBrand findById(Long id)
    {
        return brandMapper.selectPmsBrandById(id);
    }

    public List<PmsBrand> querySelective(String id, String name, Integer page, Integer size, String sort, String order)
    {
        return null;
    }

    /**
     * 修改商品品牌
     *
     * @author 张涛
     * @param brand
     */
    public int updateById(PmsBrand brand)
    {
        brand.setUpdateTime(LocalDateTime.now());
        return brandMapper.updatePmsBrand(brand);
    }

    /**
     * 删除商品品牌
     *
     * @author 张涛
     * @param id
     */
    public void deleteById(Long id)
    {
        brandMapper.deletePmsBrandById(id);
    }

    /**
     * 添加商品品牌
     *
     * @author 张涛
     * @param brand
     */
    public void add(PmsBrand brand)
    {
        brand.setAddTime(LocalDateTime.now());
        brand.setUpdateTime(LocalDateTime.now());
        brandMapper.insertPmsBrand(brand);
    }

    public List<PmsBrand> all()
    {
        return null;
    }
}
